package loupan

import (
	"hft/Http/Controller/loupan/loupan_model"
	"hft/Http/Services/loupan"
	utils "hft/Http/Utils"
	"hft/e"

	"github.com/gin-gonic/gin"
)

type WhatsApp struct{}

func (*WhatsApp) SetApp(c *gin.Context) {
	var data *loupan_model.WhatsAppBody
	if err := c.ShouldBindJSON(&data); err != nil {
		utils.FailWithMessage(e.ErrorInfo, c)
	} else {
		err = loupan.WhatsAppService.SetApp(data.Phone, data.LouID)
		if err != nil {
			utils.FailWithMessage(err.Error(), c)
		} else {
			utils.Ok(c)
		}
	}
}

var WhatsAppController = new(WhatsApp)
